﻿using System;
using System.Collections.Generic;
using System.Configuration;
using System.IO;
using System.Windows.Forms;
using System.Xml.Serialization;
using NeoModulusBusinessRulesDLLBuilder.Classes;
using NeoModulusBusinessRulesDLLBuilder.Dialogs;
using NeoModulusBusinessRulesDLLBuilder.UserControls;

namespace NeoModulusBusinessRulesDLLBuilder
{
    public partial class Main : Form
    {
        private OpenProjectWizard _openProjectWizard;
        private NewProjectWizard _newProjectWizard;
        private About _about;

        private usrObjectTree _objectTree;
        private usrObjectExplorer _objectExplorer;

        public Main()
        {
            InitializeComponent();
        }

        private void TbMainButtonClick(object sender, ToolBarButtonClickEventArgs e)
        {
            if (e.Button == tbbNew)
            {
                _newProjectWizard = new NewProjectWizard();
                _newProjectWizard.Closed += new EventHandler(NewProjectWizardClosed);
                _newProjectWizard.ShowDialog();
            }
            else if (e.Button == tbbOpen)
            {
                _openProjectWizard = new OpenProjectWizard();
                _openProjectWizard.Closed += new EventHandler(OpenProjectWizardClosed);
                _openProjectWizard.ShowDialog();
            }
            else if (e.Button == tbbAbout)
            {
                _about = new About();
                _about.ShowDialog();
            }
        }

        void OpenProjectWizardClosed(object sender, EventArgs e)
        {
            _objectTree.OpenProject(_openProjectWizard.ProjectToOpen);
        }

     
        void NewProjectWizardClosed(object sender, EventArgs e)
        {
            if (_newProjectWizard.DialogResult == DialogResult.Yes)
            {
                _objectTree.OpenProject(_newProjectWizard.txtProjectName.Text);
            }
        }
        

        private void Main_Load(object sender, EventArgs e)
        {
            _objectTree = new usrObjectTree();
            _objectTree.Dock = DockStyle.Fill;
            scMain.Panel1.Controls.Clear();
            scMain.Panel1.Controls.Add(_objectTree);



            _objectExplorer = new usrObjectExplorer();
            _objectExplorer.CurrentObjectTree = _objectTree;
            _objectExplorer.Dock = DockStyle.Fill;
            scMain.Panel2.Controls.Clear();
            scMain.Panel2.Controls.Add(_objectExplorer);
        }
    }
}
